#ifndef __MAINSVR_DATA_PREPARE__
#define __MAINSVR_DATA_PREPARE__

#include "CTAsyncCmd.h"
#include "CTHashObjectMgr.h"
#include "base/CTSingleton.h"
#include "commclass.h"

using namespace CTLib;

class CDataPrepare
{
public:
    CDataPrepare();
    ~CDataPrepare();

    //帐号信息拉取
    int GetPlayerBaseInfo(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);
	bool IsPlayerBaseInfoPrepared(unsigned int uiGID);
    int GetPlayerBaseInfoFromDB(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);

    //详细信息拉取
    int GetPlayerDetailInfo(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);
    bool IsPlayerDetailInfoPrepared(unsigned int uiGID);
    int GetPlayerDetailInfoFromDB(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);

    //详细信息拉取
    int GetPlayerDetailInfoEx1 (CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);
    bool IsPlayerDetailInfoEx1Prepared(unsigned int uiGID);
    int GetPlayerDetailInfoEx1FromDB(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);

    //SNS信息拉取
    int GetPlayerSnsDetailInfo(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);
    bool IsPlayerSnsDetailInfoPrepared(unsigned int uiGID);
    int GetPlayerSnsDetailInfoFromDB(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);

    //未激活伙伴数据
    int GetUnactPartnerInfo(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);
    bool IsUnactPartnerInfoPrepared(unsigned int uiGID);
    int GetUnactPartnerInfoFromDB(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);

    //副本详细信息
    int GetInstanceZoneDetailInfo(CTAsyncCmd* pstAsyncCmd, int iID);
    bool IsInstanceZoneDetailInfoPrepared(int iID);
    int GetInstanceZoneDetailInfoFromDB(CTAsyncCmd* pstAsyncCmd, int iID);

    //在线数据
    int GetPlayerOnlineData(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);
    bool IsPlayerOnlineDataPrepared(unsigned int uiGID);
    int GetPlayerOnlineDataFromDB(CTAsyncCmd* pstAsyncCmd, unsigned int uiGID);

private:
};

#define DATA_PREPARE  (CTSingleton<CDataPrepare>::Instance())

//player base info 信息准备
#define PREPARE_PLAYER_BASE_INFO(async_cmd_point, gid) \
    if (DATA_PREPARE->GetPlayerBaseInfo(async_cmd_point, gid) != 0)\
    {\
        return RET_DATA_NOT_READY;\
    }

#define ASSERT_PLAYER_PREPARED(gid) \
    if (DATA_PREPARE->IsPlayerBaseInfoPrepared(gid) == false)\
    {\
        CT_ERROR(("prepare error, gid %d is not in hash", gid));\
        return Done(RET_SYS_ERROR);\
    }

//player detail info 信息准备
#define PREPARE_PLAYER_DETAIL_INFO(async_cmd_point, gid) \
    if (DATA_PREPARE->GetPlayerDetailInfo(async_cmd_point, gid) != 0)\
{\
    return RET_DATA_NOT_READY;\
}

#define ASSERT_PLAYER_DETAIL_PREPARED(gid) \
    if (DATA_PREPARE->IsPlayerDetailInfoPrepared(gid) == false)\
{\
    CT_ERROR(("prepare error, gid %d is not in hash", gid));\
    return Done(RET_SYS_ERROR);\
}

//player detail info 信息准备
#define PREPARE_PLAYER_DETAIL_EX1_INFO(async_cmd_point, gid) \
    if (DATA_PREPARE->GetPlayerDetailInfoEx1(async_cmd_point, gid) != 0)\
{\
    return RET_DATA_NOT_READY;\
}

#define ASSERT_PLAYER_DETAIL_EX1_INFO(gid) \
    if (DATA_PREPARE->IsPlayerDetailInfoEx1Prepared(gid) == false)\
{\
    CT_ERROR(("prepare error, gid %d is not in hash", gid));\
    return Done(RET_SYS_ERROR);\
}


//player sns info 数据准备
#define PREPARE_PLAYER_SNS_DETAIL_INFO(async_cmd_point, gid) \
    if (DATA_PREPARE->GetPlayerSnsDetailInfo(async_cmd_point, gid) != 0)\
{\
    return RET_DATA_NOT_READY;\
}

#define ASSERT_PLAYER_SNS_DETAIL_PREPARED(gid) \
    if (DATA_PREPARE->IsPlayerSnsDetailInfoPrepared(gid) == false)\
{\
    CT_ERROR(("prepare error, gid %d is not in hash", gid));\
    return Done(RET_SYS_ERROR);\
}

//uncat partner info 数据准备
#define PREPARE_UNACT_PARTNER_INFO(async_cmd_point, gid) \
    if (DATA_PREPARE->GetUnactPartnerInfo(async_cmd_point, gid) != 0)\
{\
    return RET_DATA_NOT_READY;\
}

#define ASSERT_UNACT_PARTNER_PREPARED(gid) \
    if (DATA_PREPARE->IsUnactPartnerInfoPrepared(gid) == false)\
{\
    CT_ERROR(("prepare error, gid %d is not in hash", gid));\
    return Done(RET_SYS_ERROR);\
}

//副本大区详细信息数据准备
#define PREPARE_INSTANCE_ZONE_DETAIL_INFO(async_cmd_point, ID) \
    if (DATA_PREPARE->GetInstanceZoneDetailInfo(async_cmd_point, ID) != 0)\
{\
    return RET_DATA_NOT_READY;\
}

#define ASSERT_INSTANCE_ZONE_DETAIL_INFO_PREPARED(ID) \
    if (DATA_PREPARE->IsInstanceZoneDetailInfoPrepared(ID) == false)\
{\
    CT_ERROR(("prepare error, instance %d is not in hash", ID));\
    return Done(RET_SYS_ERROR);\
}

//player online data 数据准备
#define PREPARE_PLAYER_ONLINE_DATA(async_cmd_point, gid) \
    if (DATA_PREPARE->GetPlayerOnlineData(async_cmd_point, gid) != 0)\
{\
    return RET_DATA_NOT_READY;\
}

#define ASSERT_PLAYER_ONLINE_DATA_PREPARED(gid) \
    if (DATA_PREPARE->IsPlayerOnlineDataPrepared(gid) == false)\
{\
    CT_ERROR(("prepare error, gid %d is not in hash", gid));\
    return Done(RET_SYS_ERROR);\
}

#endif

